package solver.moves;

import java.util.List;
import java.util.Random;

import model.IncrementalCostCalculator;
import model.IncrementalValidator;
import model.SolverEnvironment;
import model.Problem;
import model.Solution;

import command.IncrementalMoveProcessToMachineCommand;
import command.Invoker;

public class RandomMachinesRandomProcessExchangeMove extends AbstractMove {

	public RandomMachinesRandomProcessExchangeMove(SolverEnvironment env) {
		super(env);
	}

	@Override
	public boolean performMove() {
				
		int movePid1 = env.getRandom().nextInt(env.getProblem().P);
		int orig_m1_index = env.getPotentialSolution().getMachineIdForProcessId(movePid1);

		int movePid2,orig_m2_index;
		do{
		    movePid2 = env.getRandom().nextInt(env.getProblem().P);			
		    orig_m2_index = env.getPotentialSolution().getMachineIdForProcessId(movePid2);
		}while(orig_m1_index==orig_m2_index);

		return testAndMakeExchange(movePid1, movePid2);
	}

}
